#!/bin/bash
work_path=`pwd`

function read_dir(){
    for file in `ls -a $1`
    do
      if [ -d $1"/"$file ]
      then
          if [[ $file == "." || $file == '..' || $file == '.git' || $file == '.idea' ]]
          then
            continue
          fi
           read_dir $1"/"$file $1
      else
        if [[ "${file##*.}"x == 'proto'x ]]
        then
            protoc -I=$(dirname $1) --plugin=protoc-gen-go=$(go env GOPATH)/bin/protoc-gen-go  --plugin=protoc-gen-micro=$(go env GOPATH)/bin/protoc-gen-micro --go_out=paths=source_relative:./ --micro_out=paths=source_relative:./ $1"/"$file
        fi
      fi
    done
}

read_dir $work_path $work_path
